
/***************************************************************************
 *	References
 ***************************************************************************/
//Create an empty object
var obj = {}; // o tambien se puede definir con "new Object();"

//reference the object
var reference = obj;

//Adding a property to the original object
obj.property = 1;

//The reference has the property too
console.debug('reference.property = '+reference.property);


/***************************************************************************
 *	More references
 ***************************************************************************/
var array = ['Ext JS','Mootools','jQuery'];
var ref = array;

array.push('prototype');

console.debug(ref.length == array.length);
console.debug(ref);

/***************************************************************************
 *	Reference to an object not to others refences
 ***************************************************************************/
//Create a new object
var obj1 = {property:'Original value'};
//creating the var ref1 referencing the original object
var ref1 = obj1;

//Set to obj1 a new object
obj1 = {property:'New Object!'};

//obj1 and ref1 are diferents
console.debug('same object = '+(obj1.property == ref1.property));
console.debug(obj1.property);
console.debug(ref1.property);

/***************************************************************************
 *	Reference to strings
 ***************************************************************************/
 
 var str = 'Hello world!';
 var refStr = str;
 
 str += ' this is Crysfel';
 
 console.debug('same string = '+(str === refStr));